package com.java.atm.Client;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class frontEnd
{
    private Scanner scanner;
    private boolean IsLogin;

    public frontEnd()
    {

            scanner = new Scanner(System.in);
            IsLogin = false;
    }

    public int printMenu()throws IOException//打印主菜单
    {


            System.out.println("1.登录");
            System.out.println("2.注册");
            System.out.println("3.存款");
            System.out.println("4.取款");
            System.out.println("5.查询");
            System.out.println("6.退出");

            System.out.print("请输入您的选择: ");
            int opt = scanner.nextInt();

            switch(opt)
            {
                case 1:
                    return opt;
                case 2:
                    return opt;
                case 3:
                    if(IsLogin)
                    {
                        System.out.println("请选择要操作的账户: 1.支票账户   2.储蓄账户");
                        int opt1 = scanner.nextInt();
                        if(opt1 == 1)
                        {
                            opt = 31;
                            return opt;
                        }else if(opt1 == 2)
                        {
                            System.out.println("请选择操作年限:1.半年   2.1年    3.5年");
                            int opt2 = scanner.nextInt();
                            switch(opt2)
                            {
                                case 1:
                                    opt = 321;
                                    break;
                                case 2:
                                    opt = 322;
                                    break;
                                case 3:
                                    opt = 323;
                                    break;
                            }

                            return opt;
                        }

                    }else
                    {
                        System.out.println("请登录后再进行操作");
                    }
                    break;
                case 4:
                    if(IsLogin)
                    {
                        System.out.println("请选择要操作的账户: 1.支票账户   2.储蓄账户");
                        int opt2 = scanner.nextInt();
                        if(opt2 == 1)
                        {
                            opt = 41;
                            return opt;
                        }else if(opt2 == 2)
                        {
                            System.out.println("请选择操作年限:1.半年   2.1年    3.5年");
                            opt2 = scanner.nextInt();
                            switch(opt2)
                            {
                                case 1:
                                    opt = 421;
                                    break;
                                case 2:
                                    opt = 422;
                                    break;
                                case 3:
                                    opt = 423;
                                    break;
                            }

                            return opt;
                        }

                    }else
                    {
                        System.out.println("请登录后再进行操作");
                    }

                    break;
                case 5:
                    if(IsLogin)
                    {
                        return opt;
                    }else
                    {
                        System.out.println("请登录后再进行操作");
                    }

                    break;

                case 6:
                    return opt;
                default:
                    break;

            }

            return 0;


    }

    public void setLogin(boolean b)
    {
        IsLogin = b;
    }
}
